<template>
  <div class="login-container">
    <div class="login-left-container">
      <div class="login-left-container-title">
        智能制造&nbsp;&nbsp;&nbsp;&nbsp;智享未来
      </div>
      <div class="login-left-container-desc">
        智能的数据采集体系,完整的数据汇聚,分析服务体制
      </div>
      <div class="login-left-container-pic"></div>
    </div>
    <div class="login-right-container">
      <div class="login-title">数控系统检测档案查询</div>
      <div class="login-bottom-container">
        <a-form :form="form" @submit="handleSubmit">
          <a-form-item class="single-form-container">
            <span class="single-form-title">用户名:</span>
            <a-input
              class="mobile-input"
              ref="mobile"
              v-decorator="[
                'username',
                {
                  rules: [{ required: true, message: '请输入用户名' }]
                }
              ]"
            />
          </a-form-item>
          <a-form-item class="single-form-container">
            <span class="single-form-title">密码:</span>
            <a-input
              class="mobile-input"
              v-decorator="[
                'password',
                { rules: [{ required: true, message: '请输入密码' }] }
              ]"
            />
          </a-form-item>
          <a-form-item class="single-form-container">
            <a-button type="primary" html-type="submit" class="login-btn"
              >登 录</a-button
            >
          </a-form-item>
        </a-form>
      </div>
    </div>
  </div>
</template>

<script>
import GLOBAL from "@/api/global_variable";
import api from "@/server/ncCheckConfig";

export default {
  name: "Middle",
  components: {
  },
  data() {
    return {
      ip: GLOBAL.ip,
      form: this.$form.createForm(this, { name: "coordinated" }),
    };
  },
  methods: {
    // 点击登录
    handleSubmit(e) {
      e.preventDefault();
      this.form.validateFields((err, values) => {
        if (!err) {
          api.login(values).then(res=>{
            if(res.msgCode != 0){
              return
            }
            localStorage.setItem("phone", res.data.accountName)
            localStorage.setItem("username", res.data.username)
            this.$router.push("/ncCheckList");
          })
        }
      });
    }
  }
};
</script>

<style scoped="scoped">
@import "./style.css";
</style>
